package edu.nf.bs.service.impl;

import com.github.pagehelper.PageInfo;
import edu.nf.bs.dao.TransferMapper;
import edu.nf.bs.entity.Stations;
import edu.nf.bs.entity.Transfer;
import edu.nf.bs.exception.AddException;
import edu.nf.bs.service.TransferService;

import java.util.List;

public class TransferServiceImpl implements TransferService {
    private TransferMapper mapper;

    public void setMapper(TransferMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public PageInfo<Transfer> pageTransfer(String logisticsId) {
        List<Transfer> transfers = mapper.queryLogisticsId(logisticsId);
        PageInfo<Transfer> transferPageInfo = new PageInfo<>(transfers);
        return transferPageInfo;
    }

    @Override
    public void addStations(Transfer transfer) {
        Integer integer = mapper.addTransfer(transfer);
        if(integer!=1){
            throw new AddException("添加站点信息失败！！！！");
        }
    }

    @Override
    public Transfer queryTransferAddress(String logisticsId) {
        Transfer transfer = mapper.queryTransferAddress(logisticsId);
        return transfer;
    }

    @Override
    public Transfer queryTransferAddress1(String logisticsId) {
        Transfer transfer = mapper.queryTransferAddress1(logisticsId);
        return transfer;
    }

    @Override
    public List<Integer> queryTransferStatus(String logisticsId) {
        List<Integer> integers = mapper.queryTransferStatus(logisticsId);
        return integers;
    }

    @Override
    public void updateTransfer(String logisticsId) {
        Integer integer = mapper.updateTransfer(logisticsId);
        if(integer==0){
            throw new AddException("更新物流失败！！！！");
        }
    }

    @Override
    public String queryTransferId(String logisticsId) {
        String s = mapper.queryTransferId(logisticsId);
        return s;
    }
}
